<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;

class NianjiController extends AdminbaseController {
    public function index() {
        $p=1;
        if (isset($_GET['p'])){
            $p=$_GET['p'];
        }
        $queryDesc='order by id';
        
        $postData=array();
        $where='';
        $postData['p']=$p;
        if (isset($_POST['name']) && !empty($_POST['name'])){
            $postData['name']=addslashes(trim($_POST['name']));
            $where=' where sname ="'.$postData['name'].'" ';
        }
         
        $Model = M();
        
        $query=$Model->query("SELECT count(id) as count FROM `baoming` ".$where."  ");
        $count=$query[0]['count'];
        $page = $this->page($count, 10, $p);
        $bInfo=$Model->query("SELECT * FROM `baoming` ".$where."  ".$queryDesc." limit ".(($p-1)*10).",10 ");
        $theData=array(); 
        foreach ($bInfo as $v){
            
            $getQD=$Model->query("SELECT * FROM `qdui` where id='".$v['qid']."' limit 0,1 ");
             
            if (isset($getQD[0]['name']) && !empty($getQD[0]['name'])){
                $theData[]=array('id'=>$v['id'],'name'=>$v['sname'],
                    'qdname'=>$getQD[0]['name'],
                    'createtime'=>$v['createtime']
                );
            }
            
        }
        $this->assign("postData", $postData);
        $this->assign("page", $page->show('Admin'));
        $this->assign("thedata", $theData);
        
        $this->display();
    }
    
  
  
 
}
